package com.dks.controller;

import com.dks.repository.ITaskRepository;
import com.dks.repository.impl.RewardRepository;
import com.dks.result.Result;
import com.dks.result.ResultInfo;
import com.dks.result.ResultModel;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RequestMapping("reward")
@RestController
public class RewardController {

    private RewardRepository rewardRepository;

    @Autowired
    public RewardController(final RewardRepository rewardRepository) {
        this.rewardRepository = rewardRepository;
    }

    /**
     * @Author: Ah Nan
     * @Description: 获取互动消息列表
     * @Date: 9:52 2020/4/23
     * @Modificd By:
     * @Param: parentId 家长id
     * @Param: rewardType 奖励类型：1、妍值,2、学分
     * @Param: pageNum 页码
     * @Param: pageSize 条数
     * @return:
     * @throw: 请描述异常信息
     */
    @GetMapping("get-reward-list")
    public ResultModel<Object> getTaskInfo(Integer parentId, Integer pageNum, Integer pageSize,Integer rewardType) {

        if (null == pageNum) {
            return Result.makeResult(ResultInfo.ERR_PARAM_NULL, "pageNum");
        }
        if (null == pageSize) {
            return Result.makeResult(ResultInfo.ERR_PARAM_NULL, "pageSize");
        }
        if (null == parentId) {
            return Result.makeResult(ResultInfo.ERR_PARAM_NULL, "parentId");
        }
        if (null == rewardType) {
            return Result.makeResult(ResultInfo.ERR_PARAM_NULL, "rewardType");
        }
        return rewardRepository.getTaskInfo(parentId,pageNum,pageSize,rewardType);
    }


}
